﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameConfig : MonoBehaviour {

    public string[] LogGroups = new string[] { "Net", "Test1", "Test2" };
    public bool EnableLog = true;
    public bool WriteLog = true;

    void Start()
    {
        Utility.Log.EnableLog = EnableLog;
        Utility.Log.m_bWriteLogFile = WriteLog;
        SetLogUser();
    }

    public void SetLogUser()
    {
        LogGroupData m_logGroupData = Resources.Load("LogConfig", typeof(LogGroupData)) as LogGroupData;
        if (m_logGroupData != null)
        {
            Utility.Log.MaxLogLevel =  (Utility.Log.LogLevel)m_logGroupData.logLevel;
            try
            {
                foreach (var item in LogGroups)
                {
                    Utility.Log.CloseGroup(item);
                }
            }
            catch (System.Exception ex)
            {
                Debug.LogError(ex.Message);
            }

            for (int i = 0; i < m_logGroupData.LogUsers.Count; i++)
            {
                Utility.Log.OpenGroup(m_logGroupData.LogUsers[i]);
            }
        }
    }
#if UNITY_EDITOR
	// Update is called once per frame
    void Update()
    {
        Utility.Log.EnableLog = EnableLog;
        Utility.Log.m_bWriteLogFile = WriteLog;
    }
#endif
}
